package com.humanminoritygame.model.mock;

import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import com.humanminoritygame.model.User;
import com.humanminoritygame.model.UserRepo;

public class MockUserRepo implements UserRepo {
  private SortedSet<User> users = new TreeSet<User>();
  
  public MockUserRepo(){ 
    User user1 = new User("Juan", "1234", "juan@hotmail.com");
    User user2 = new User("Pablo", "1234", "pablin@hotmail.com");
    User user3 = new User("Segundo", "1234", "second@hotmail.com");
    addUser(user1);
    addUser(user2);
    addUser(user3);
  }
  

  @Override
  public void addUser(User user) {
    users.add(user);
    //TODO: el tree set se encarga de chequear que no este repetido?
  }

  @Override
  public void delUser(User user) {
    users.remove(user);
  }

  @Override
  public User getUser(String name, String password) {
    Iterator<User> i = users.iterator();
    while(i.hasNext()){
      User resp = i.next();
      if(resp.getName().equals(name) && resp.getPassword().equals(password)){
        return resp;
      }
    }
    return null;
  }

  
  @Override
  public User getUserByName(String name) {
    Iterator<User> i = users.iterator();
    while( i.hasNext()){
      User resp = i.next();
      if(resp.getName().equals(name)){
        return resp;
      }
    }
    return null;
  }

  @Override
  public SortedSet<User> getUsers() {
    return users;
  }


  @Override
  public Set<User> getRobots() {
    // TODO Auto-generated method stub
    // este metodo tiene que reemplazar al re arriba ^
    return null;
  }


  @Override
  public User getUserById(Long userId) {
    // TODO Auto-generated method stub
    return null;
  }


  @Override
  public SortedSet<User> getHumanUsers() {
    // TODO Auto-generated method stub
    return null;
  }
}
